package mo.common;

import java.util.List;

public class ListNode {

    public int val;
    public ListNode next;
    public ListNode(int x) {
        val = x;
        next = null;
    }

    public static ListNode convertList2ListNode(List<Integer> nums) {
        ListNode head = new ListNode(0);
        ListNode next = head;
        for (int i = 0; i < nums.size(); i++) {
            next.next = new ListNode(nums.get(i));
            next = next.next;
        }
        return head.next;
    }

    public void print() {
        ListNode temp = this;
        while (temp != null) {
            System.out.print(temp.val);
            System.out.print("--->");
            temp = temp.next;
        }
        System.out.println();
    }
}
